package tasks.OpportunitiesBaseData;
import java.io.IOException;

import core.FileOperator;
/**
 * Description   : Functional Test Script
 * @author angel.tsvetkov
 */
public class ContentRule
{
	private String sqlRule;
	
	public ContentRule(String ruleFileName)
	{
		sqlRule = ruleLoader(ruleFileName);
	}
	
	private String ruleLoader(String ruleName)
	{
		String ruleTemplate = "";
		String fileParentDir = "tasks\\OpportunitiesBaseData\\Rules\\";
		try {
			ruleTemplate = FileOperator.getContents(fileParentDir + ruleName);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return ruleTemplate;
	}
	
	public String getRule(Pattern... patterns)
	{
		if(sqlRule != null)
		{
			for(Pattern pattern:patterns)
			{
				sqlRule = sqlRule.replace(pattern.getPattern(), pattern.getValue());
			}
		}
		
		return sqlRule;
	}
	
}

